#ifndef __GAMEMANAGER_HPP__
#define __GAMEMANAGER_HPP__ 1

#include <functional>
#include <stack>
#include <thread>

#include "MediaManager.hpp"
//#include "UnitManager.hpp"

class CRenderer;
class CUnitManager;

//const int TICKS_PER_SECOND = 25;
//const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
//const int MAX_FRAMESKIP = 10;

class CGameManager
{
public:
	typedef function<bool (CGameManager*)> ManagerCb;

	CGameManager();
	~CGameManager();

	const CUnitManager& UnitManager() const { return *unitManager; }
	CUnitManager& UnitManager() { return *unitManager; }
	const CMediaManager& MediaManager() const { return *mediaManager; }
	CMediaManager& MediaManager() { return *mediaManager; }
	//const CRenderer& Renderer() const { return *renderer; }
	//CRenderer& Renderer() { return *renderer; }

	bool Initialize();
	void Shutdown();
	bool Run();

	/* State Handlers */
	bool RunMenu();
	bool RunGame();

private:
	CRenderer* renderer;
	CUnitManager* unitManager;
	CMediaManager* mediaManager;

	bool initialized;
	bool running;
	DWORD next_game_tick;
	std::stack<ManagerCb> states;

	const CGameManager& operator=(const CGameManager &) const { return *this; }
};

#endif